Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(crypto): Serialize sender data msk in base64 instead of numbers #4450

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

BillCarsonFr
Copy link
Member

@BillCarsonFr BillCarsonFr commented Dec 20, 2024

Follow up of #4449

While adding snapshot test, I detected that sender's data KnownSenderData was serializing the cross-signing master key as an array of number. This PR changes that and now serialize the key as a base64 string, adding migration for the old format.

  • Public API changes documented in changelogs (optional)

Signed-off-by:

@BillCarsonFr BillCarsonFr force-pushed the valere/add_some_crypto_insta_snapshot_tests branch from 01bf4ba to 4e6c060 Compare December 20, 2024 18:03
Base automatically changed from valere/add_some_crypto_insta_snapshot_tests to main December 20, 2024 18:52
@BillCarsonFr BillCarsonFr force-pushed the valere/serialize_known_sender_data_b64 branch from 5496d77 to 3c94504 Compare December 23, 2024 08:39
@BillCarsonFr BillCarsonFr marked this pull request as ready for review December 23, 2024 08:44
@BillCarsonFr BillCarsonFr requested review from a team as code owners December 23, 2024 08:44
@BillCarsonFr BillCarsonFr requested review from Hywan, poljar and andybalaam and removed request for a team and Hywan December 23, 2024 08:44
pub master_key: Box<Ed25519PublicKey>,
}

/// In an initial version the master key was serialized as an array of number,
/// it is now exported in base64. This code adds backward compatibility.
pub(crate) fn deserialize_sender_msk_base64_or_array<'de, D>(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with this serde visitor pattern. Let me know if it is sane or if there is a prefferred method? I am not sure about the error mappings

@richvdh
Copy link
Member

richvdh commented Jan 2, 2025

Filed #4459 about the test failure

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 85.09%. Comparing base (d649606) to head (5ff556f).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...x-sdk-crypto/src/olm/group_sessions/sender_data.rs 73.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4450      +/-   ##
==========================================
- Coverage   85.12%   85.09%   -0.04%     
==========================================
  Files         283      283              
  Lines       31775    31790      +15     
==========================================
+ Hits        27048    27051       +3     
- Misses       4727     4739      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, and the error mappings look about right.

@poljar should Edd25519PublicKey serialize as base64 by default?

@poljar
Copy link
Contributor

poljar commented Jan 7, 2025

This looks good to me, and the error mappings look about right.

@poljar should Edd25519PublicKey serialize as base64 by default?

No, only if we serialize into JSON.

@poljar
Copy link
Contributor

poljar commented Jan 7, 2025

This looks good to me, and the error mappings look about right.
@poljar should Edd25519PublicKey serialize as base64 by default?

No, only if we serialize into JSON.

To expand on this, I think this PR is fine, but we don't want to move the base64 serialization into vodozemac, where Ed25519PublicKey is defined.

@BillCarsonFr BillCarsonFr force-pushed the valere/serialize_known_sender_data_b64 branch from 3c94504 to 5ff556f Compare January 8, 2025 12:22
@BillCarsonFr BillCarsonFr merged commit 9e69b63 into main Jan 8, 2025
40 checks passed
@BillCarsonFr BillCarsonFr deleted the valere/serialize_known_sender_data_b64 branch January 8, 2025 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants